﻿<UserControl xmlns:my="clr-namespace:WpfControlLibrary;assembly=WpfControlLibrary"  x:Class="YLServerInterface.UserControls.ImageCutter"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:s="clr-namespace:YLServerInterface.UserControls.DiagramDesigner"
             mc:Ignorable="d" 
             x:Name="myc"
             d:DesignHeight="259" d:DesignWidth="427" Loaded="UserControl_Loaded" BorderThickness="3" BorderBrush="#FF838383" >
    <UserControl.Resources>
        <!-- MoveThumb Template -->
        <ControlTemplate x:Key="MoveThumbTemplate" TargetType="{x:Type s:MoveThumb}">
            <Rectangle Fill="Transparent"/>
        </ControlTemplate>

        <!-- ResizeDecorator Template -->
        <ControlTemplate x:Key="ResizeDecoratorTemplate" TargetType="{x:Type Control}">
            <Grid>
                <s:ResizeThumb Height="3" Cursor="SizeNS" Margin="0 -4 0 0"
                       VerticalAlignment="Top" HorizontalAlignment="Stretch"/>
                <s:ResizeThumb Width="3" Cursor="SizeWE" Margin="-4 0 0 0"
                       VerticalAlignment="Stretch" HorizontalAlignment="Left"/>
                <s:ResizeThumb Width="3" Cursor="SizeWE" Margin="0 0 -4 0"
                       VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
                <s:ResizeThumb Height="3" Cursor="SizeNS" Margin="0 0 0 -4"
                       VerticalAlignment="Bottom" HorizontalAlignment="Stretch"/>
                <s:ResizeThumb Width="7" Height="7" Cursor="SizeNWSE" Margin="-6 -6 0 0"
                       VerticalAlignment="Top" HorizontalAlignment="Left"/>
                <s:ResizeThumb Width="7" Height="7" Cursor="SizeNESW" Margin="0 -6 -6 0"
                       VerticalAlignment="Top" HorizontalAlignment="Right"/>
                <s:ResizeThumb Width="7" Height="7" Cursor="SizeNESW" Margin="-6 0 0 -6"
                       VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
                <s:ResizeThumb Width="7" Height="7" Cursor="SizeNWSE" Margin="0 0 -6 -6"
                       VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
            </Grid>
        </ControlTemplate>


        <!-- Designer Item Template-->
        <ControlTemplate x:Key="DesignerItemTemplate" TargetType="ContentControl">
            <Grid DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                <s:MoveThumb Template="{StaticResource MoveThumbTemplate}" Cursor="SizeAll"/>
                <Control Template="{StaticResource ResizeDecoratorTemplate}"/>
                <ContentPresenter Content="{TemplateBinding ContentControl.Content}"/>
            </Grid>
        </ControlTemplate>
    </UserControl.Resources>
    <Grid>
        <Image    Name="img" Stretch="Fill" SizeChanged="img_SizeChanged"  />
        <Canvas>
            <ContentControl  
                Name="rect"
                Template="{StaticResource DesignerItemTemplate}" 
                Canvas.Left="1"
                Canvas.Top="1"
                 MouseWheel="rect_MouseWheel"
                >
                <Rectangle   
                    Opacity="1" 
                   HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                            IsHitTestVisible="False" />
            </ContentControl>
            <Label Content="图片分辨率不符合裁剪要求。" Height="Auto" HorizontalAlignment="Center" Margin="0" Name="labError" VerticalAlignment="Center" FontSize="20" Visibility="Hidden" />

        </Canvas>
    </Grid>
</UserControl>

    